package cn.bugstack.mybatis.session;

import cn.bugstack.mybatis.builder.xml.XMLConfigBuilder;
import cn.bugstack.mybatis.session.defaults.DefaultSqlSessionFactory;

import java.io.Reader;

/**
 * @Description 该类作为整个MyBatis的入口，提供建造者工厂，包装XML文件解析，并返回对应的SqlSessionFactory处理类
 * XML文件被解析后，会被保存到Configuration类中。
 * @Classname SqlSessionFactoryBuilder
 * @Date 2024/3/28 15:01
 * @Created by aazhao
 */
public class SqlSessionFactoryBuilder {
    public SqlSessionFactory build(Reader reader) {
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder(reader);
        return build(xmlConfigBuilder.parse());
    }

    public SqlSessionFactory build(Configuration config) {
        return new DefaultSqlSessionFactory(config);
    }


}
